<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<ul class="breadcrumb">
			<li>
				<i class="icon-home home-icon"></i>
				<a href="#">系统首页</a>
			</li>
			<li class="active">
				设备管理
			</li>
            <li class="active">
				设备审核
			</li>
		</ul><!-- .breadcrumb -->
	</div>
	<!-- Main content -->
    <div class="page-content">
    	<div class="row">
    	    <div class="page-header">
    			<h1>设备信息审核列表</h1>
    		</div>
            <div class=" col-md-12 col-sm-12 col-xs-12 form">
                <div class="row">
                <form action="<?php echo base_url().'admin/device/check'?>" method="get">
                    <div class="wh">
                    	<label>设备编码：</label>
                        <input type="text"  name="device_id" value="<?php if (isset($device_id))echo $device_id;?>"/>
                    </div>
                    <div class="wh">
                    	<label>设备类型：</label>
                    	<select name="device_category" id="device_category" style="height: 23px;">
                            <option value="">全部</option>
                            <?php if (isset($category)){
                                foreach ($category as $val){
                            ?>
							<option value="<?php echo $val->id;?>" <?php if (isset($device_category)&&$device_category == $val->id)echo "selected";?>><?php echo $val->name;?></option>
							<?php }
                                }?>
						</select>
                    </div>
                    <div class="wh">
                    	<label>登记时间：</label>
                        <input id="date" type="text" name="create_time" value="<?php if (isset($create_time))echo $create_time;?>" />
                    </div>
                    <div class="wh">
                    	<label>用户姓名：</label>
                        <input type="text" name="user_name" value="<?php if (isset($user_name))echo $user_name;?>" />
                    </div>
                    <div class="wh">
                    	<label>手机号码：</label>
                        <input type="text" name="phone" value="<?php if (isset($phone))echo $phone;?>" />
                    </div>
                    <div class="wh">
                    <button class="btn btn-sm btn-info" type="submit"><i class="icon-search"></i>查询</button>
                    </div> 
                </form>
                </div>
            </div>
            <div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
				<form action="" method="post" id="delForm">
				<input type="hidden" name="change_name" id="change_name" value="">
				<input type="hidden" name="change_value" id="change_value" value="">
					<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th class="center" style="width: 3%;">
									<label>
										<input type="checkbox" class="ace" />
										<span class="lbl"></span>
									</label>
								</th>
								<th>姓名</th>
								<th>电话</th>
								<th>编码</th>
								<th>类型</th>
                                <th>品牌</th>
                                <th>型号</th>
                                <th>出厂日期</th>
                                <th>状态</th>
                                <th>登记时间</th>
                                <th style="width: 20%;">操作</th>
							</tr>
						</thead> 
						
						<tbody>
						<?php if (isset($result)&&count($result)>0){
                            	foreach ($result as $device){
                            	?>
							<tr>
								<td class="center">
                                	<p>
									<label>
										<input type="checkbox" class="ace" name="num[]" value="<?php echo $device->id;?>"/>
										<span class="lbl"></span>
									</label>
                                    </p>
								</td>
								<td><p><?php echo $device->card_name;?></p></td>
                                <td><p><?php echo $device->login_name;?></p></td>
                                <td><p><?php echo $device->device_no;?></p></td>
                                <td><p><?php echo $device->category_name.'/'.$device->type_name;?></p></td>
                                <td><p><?php echo $device->brand;?></p></td>
                                <td><p><?php echo $device->model;?></p></td>
                                <td><p><?php echo $device->out_year;?></p></td>
                                <td><p><?php 
										if($device->status == 0){
											echo "未审核";
										}elseif($device->status == 1){
											echo "已审核";
										}elseif($device->status == 2){
											echo "审核不通过";
										}
								?></p></td>
								<td><p><?php echo $device->create_time;?></p></td>
                                <td>
                                	<a class="btn btn-sm btn-info" href="<?php echo base_url().'admin/device/edit_device_check/'.$device->id;?>"><i class="icon-edit"></i>审核处理</a>
								    <a class="btn btn-sm btn-info" href="<?php echo base_url().'admin/device/updet_device_check/'.$device->id;?>"><i class="icon-cogs"></i>信息编辑</a>
                                </td>
    						</tr>
    						<?php }
                            }else{?>
                            <tr>
                            	<td colspan="11">无数据</td>
                            </tr>
                            <?php }?>
                            </tbody>
                         </table>
                         </form>
                     </div><!-- /.table-responsive -->
				</div>
                <div class="col-sm-12">
                	<div class="modal-footer no-margin-top">
	                	<div class="pull-left record">
							共<?php echo $count;?>条记录
	                    </div>
                		<?php if (isset($page))echo $page;?>
                	</div>
                </div>
            </div><!-- /.row -->
		</div><!-- /.page-content -->
	</div><!-- /.main-content -->
	<div id="upModal" class="modal fade" role="dialog" aria-hidden="true">
		<div class="modal-dialog" style="width: 300px">
			<div class="modal-content">
				<div class="modal-header">
				  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				  <h3>提示信息</h3>
				</div>
				<div class="modal-body">
				  <p>确定要更改此设备的状态吗？</p>
				</div>
				<div class="modal-footer">
				  <a id="upbtn" href="#" class="btn btn-danger">确定</a>
				  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
				</div>
			</div>
		</div>
	</div>
	<div id="delsomeModal" class="modal fade" role="dialog" aria-hidden="true">
		<div class="modal-dialog" style="width: 300px">
			<div class="modal-content">
				<div class="modal-header">
				  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				  <h3>提示信息</h3>
				</div>
				<div class="modal-body">
				  <p>确定要删除所选设备吗？</p>
				</div>
				<div class="modal-footer">
				  <button id="delsomebtn" type="submit" class="btn btn-danger">确定</button>
				  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
				</div>
			</div>
		</div>
	</div>
	<div id="editsomeModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 450px;height: 500px;">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>批量编辑</h3>
			</div>
			<div class="modal-body" style="height: 100px;">
				<div class="col-xs-10">
					<label>需要更改的属性：</label><br>
				    <select style="width: 350px;" id="change_name1" name="change_name1" onchange="show_value()">
                    	<option value="">未设置</option>
                    	<option value="device_id">设备标示ID</option>
                    	<option value="price">设备价格</option>
                    	<option value="service_price">服务费用</option>
                    	<option value="service_package">服务套餐</option>
                    	<option value="seller_id">销售人员</option>
                    	<option value="service_admin_id">服务专员</option>
                    </select>
				</div>
			</div>
			<div class="modal-body" style="height: 100px;">
				<div class="col-xs-10">
					<label>更改后的值：</label><br>
					<div id="change">
					   <input type="text" name="change_value1" value="" id="change_value1" style="width: 350px;">
					   <select name="change_value2" id="change_value2" style="width: 350px;display:none;">
					       <option value="">未设置</option>
					       <?php if(isset($service_package)){
					       foreach ($service_package as $val){?>
					           <option value="<?php echo $val->id;?>"><?php echo $val->name;?></option>
					       <?php }
					       }?>
					   </select>
					   <select name="change_value3" id="change_value3" style="width: 350px;display:none;" >
					       <option value="">&nbsp;</option>
					       <?php if(isset($seller)){
					       foreach ($seller as $val){?>
					           <option value="<?php echo $val->id;?>"><?php echo $val->login_name.'('.$val->user_name.')';?></option>
					       <?php }
					       }?>
					   </select>
					   <select name="change_value4" id="change_value4" style="width: 350px;display:none;">
					       <option value="">&nbsp;</option>
					       <?php if(isset($service)){
					       foreach ($service as $val){?>
					           <option value="<?php echo $val->id;?>"><?php echo $val->login_name.'('.$val->user_name.')';?></option>
					       <?php }
					       }?>
					   </select>
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-info" id="add_btn">保存</button>
				<a href="#" class="btn btn-danger" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
			</form>
		</div>
	</div>
</div>
	<script type="text/javascript">
	function upmodal(id,status){
		$("#upbtn").attr('href','<?php echo base_url().'admin/device/status_device/'?>'+id+'/'+status);
	    $('#upModal').modal('show');
	}
    function del_or_edit(type){
    	$("#delForm").attr("action", "<?php echo base_url().'admin/device/del_some_device'?>");
    	if(checkSelect()){
	    	$('#delsomeModal').modal('show');
		}else{
			alert('请选择正确的记录进行删除');
		}
    }
    $("#delsomebtn").click(function(){
		$("#delForm").submit();
    });
    function show_value(){
    	var vs = $('#change_name1').val();
    	if(vs == 'service_package'){
    		$('#change_value2').show();
    		$('#change_value1').hide();
    		$('#change_value3').hide();
    		$('#change_value4').hide();
    	}else if(vs == 'seller_id'){
    		$('#change_value3').show();
    		$('#change_value1').hide();
    		$('#change_value2').hide();
    		$('#change_value4').hide();
    	}else if(vs == 'service_admin_id'){
    		$('#change_value4').show();
    		$('#change_value1').hide();
    		$('#change_value2').hide();
    		$('#change_value3').hide();
    	}else{
    		$('#change_value1').show();
    		$('#change_value2').hide();
    		$('#change_value3').hide();
    		$('#change_value4').hide();
    	}
    }
    $("#add_btn").click(function(){
		if($('#change_name1').val() == ''||($('#change_value1').val() == ''&&$('#change_value2').val() == ''&&$('#change_value3').val() == ''&&$('#change_value4').val() == '')){
			alert('请填写完整后保存');
		}else{
			var name = $('#change_name1 option:selected').val();
			$('#change_name').val(name);
			if(name == 'service_package'){
				$('#change_value').val($('#change_value2').val());
			}else if(name == 'seller_id'){
				$('#change_value').val($('#change_value3').val());
			}else if(name == 'service_admin_id'){
				$('#change_value').val($('#change_value4').val());
			}else{
				$('#change_value').val($('#change_value1').val());
			}
			$("#delForm").submit();
		}
    });
    $(function () {
        $('#date').datetimepicker({
            format: 'yyyy-mm-dd', 'autoclose': true, minView: 2,language: 'zh-CN'
        });
    });
	</script>